package cn.edu.lingnan.controller;

import cn.edu.lingnan.pojo.C_V;
import cn.edu.lingnan.pojo.Vac;
import cn.edu.lingnan.service.C_VService;
import cn.edu.lingnan.service.VacService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/c_v")
public class C_VController {
    @Autowired
    @Qualifier("c_vService")
    private C_VService c_vService;


    @RequestMapping("/selectC_VAll")
    // 查找所有的疫苗信息
    public String findAllC_V(Model model){
        model.addAttribute("allC_V",c_vService.findAllVac_Over_Num());
//        System.out.println();
        return "admin/allC_V";
    }

    @RequestMapping("/insertInfotoC_V")
    //新增一条疫苗信息
    public String insertC_V(C_V c_v) {
        c_vService.insertInfotoC_V(c_v);
        return "redirect:/c_v/selectC_VAll";//这里应该跳转到查询所有页面
    }

    @RequestMapping("/toUpdateInfoC_V")
    public String toUpdateInfoC_V(String country_id,String vac_id,Model model){
        C_V c_v = c_vService.findVac_Over_NumByCountry_idAndVac_id(country_id, vac_id);
        model.addAttribute("c_v",c_v);
        return "admin/updateC_V";
    }
    @RequestMapping("/updateInfoC_V")
    public String updateC_V(C_V c_v){
        c_vService.updataC_V(c_v);
        return "redirect:/c_v/selectC_VAll";
    }
    @RequestMapping("/deleteC_V")
    public String deleteC_V(String country_id, String vac_id){
        c_vService.deleteC_V(country_id,vac_id);
        return "redirect:/c_v/selectC_VAll";
    }
}
